//compose([fn1,fn2,fn3](args))
// fn1(fn2(fn3(args)))
function componse(...funs) {
  if (funs.length === 0) {
    return (arg) => arg;
  }
  console.log(funs,'funs');
  if (funs.length === 1) {
    return funs[0];
  }
  const res = funs.reduce((pre, cur) => {
    return (...args) => pre(cur(...args));
  });

  return res;
}
const fn1 = (...args) => {
  console.log("fn1:", ...args);
};
const fn2 = (...args) => {
  console.log("fn2:", ...args);
};
const fn3 = (...args) => {
  console.log("fn3:", ...args);
};
componse(fn1,fn2,fn3)(1, 2, 3,4);
